<?php

namespace app\index\controller;

use app\common\controller\IndexBase;
use app\common\model\AiImage;
use app\common\model\ProjectFiles;

class Callback extends IndexBase
{
    public function ossCallBack()
    {
        $data = input();
        file_put_contents('ossCallBack.txt',date("Y-m-d") . "\r\n",FILE_APPEND);
        file_put_contents('ossCallBack.txt',json_encode($data) . "\r\n\r\n\r\n",FILE_APPEND);
        if (isset($data['object']) && isset($data['my_var1'])) {
            $item = AiImage::where("id",$data['my_var1'])->find();
            if ($item) {
                $item->store = "ali";
                $item->save();
                delFile($data['object']);
            } else {
                file_put_contents('ossCallBack.txt', "{$data['my_var1']}\r\n\r\n\r\n",FILE_APPEND);
            }
        }
        return json(['status'=>"success"]);
    }
}